import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('../views/Index.vue'),
      meta: {
        title: "国际教育网升学中心"
      }
    },
    {
      path: '/kefu',
      name: 'kefu',
      component: () => import('../views/Kefu.vue'),
      meta: {
        title: "客服"
      }
    },
    {
      path: '/shoping',
      name: 'shoping',
      component: () => import('../views/Shoping.vue'),
      meta: {
        title: "客服"
      }
    },
    {
      path: '/center',
      name: 'center',
      component: () => import('../views/Center.vue'),
      meta: {
        title: "客服"
      }
    }
  ]
})

router.beforeEach(async (to, form, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router
